<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
    // 已注册的帐号信息： 
            let persons = [
                { "username":"xiaoming1","password":"1111" },
                { "username":"admin1","password":"222" },
                { "username":"xiaoming3","password":"33333" },
            ];

    //用户输入的帐号及密码： 
        let user = { username:"admin1",password:"12345" }

        let flg = false; //未注册过
        //1)、判断当前用户是否注册过：
        for(let obj of persons){

            //如果当前帐号和已注册的帐号有相等则说明该已注册过
            if(user.username == obj.username){
                flg = true;
            }
        }

        if(flg){  //该帐号已注册过
            alert(`当前帐号已注册过`);
        }else{//该帐号未注册过
            persons.push(user);
            console.log(persons);
        }


    </script>
</head>
<body>
    
</body>
</html>